{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "import fourier\n",
    "from smoothness_measure import smoothness_measure_by_delta"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def calc_sm(actions):\n",
    "    freqs, amps = fourier.fourier_transform(actions, 0.1)\n",
    "    sm = fourier.smoothness(amps)\n",
    "    return sm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.3122623321024132 0.36\n"
     ]
    }
   ],
   "source": [
    "a = np.array([1, 5, 3, 2, 4])\n",
    "print(calc_sm(a), smoothness_measure_by_delta(pd.DataFrame(a, columns=['a']), ['a'])[0]/len(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.85065080835204 0.16\n"
     ]
    }
   ],
   "source": [
    "a = np.array([1, 2, 3, 4, 5])\n",
    "print(calc_sm(a), smoothness_measure_by_delta(pd.DataFrame(a, columns=['a']), ['a'])[0]/len(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.4994424081913666 0.16\n"
     ]
    }
   ],
   "source": [
    "a = np.array([3, 3, 2, 1, 3])\n",
    "print(calc_sm(a), smoothness_measure_by_delta(pd.DataFrame(a, columns=['a']), ['a'])[0]/len(a))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "dcs_py38",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.13"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "9aabd176a0f50fb7955ff2f90c45e48e18b6943f41a6242db6acd9cab2d045db"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
